﻿namespace Cos.Module.Form.Data
{
    using System;
    using System.Collections.Generic;

    using Cos.Core.Model.Common;
    using Cos.Core.Model.Form;

    /// <summary>
    /// FormRepository signature interface.
    /// </summary>
    public interface IFormRepository
    {
        /// <summary>
        /// Get the form from form id
        /// </summary>
        /// <param name="formId">the id of the form</param>
        /// <param name="culture">the culture</param>
        /// <param name="isLiveMode">true if the user is viewing the site in live mode</param>
        /// <returns>A form Object.</returns>
        Form GetForm(int formId, Culture culture, bool isLiveMode);

        /// <summary>
        /// Get the form from form id
        /// </summary>
        /// <param name="formId">the id of the form</param>
        /// <param name="cultureId">the culture id</param>
        /// <param name="isLiveMode">true if the user is viewing the site in live mode</param>
        /// <returns>A form Object.</returns>
        Form GetForm(int formId, int cultureId, bool isLiveMode);

        /// <summary>
        /// Get the form from form id
        /// </summary>
        /// <param name="formId">the id of the form</param>
        /// <param name="cultureCode">the culture id</param>
        /// <param name="isLiveMode">true if the user is viewing the site in live mode</param>
        /// <returns>A form Object.</returns>
        Form GetForm(int formId, string cultureCode, bool isLiveMode);

        /// <summary>
        /// Used for polls. Get the count of for each element choice for a form element
        /// </summary>
        /// <param name="formElement">The form element we want the count for</param>
        /// <returns>A dictionary of [element choice value, count]</returns>
        IDictionary<string, int> GetAnswerCount(int formElement);


        /// <summary>
        /// Submits the form.
        /// </summary>
        /// <param name="submission">The submission object.</param>
        /// <param name="isLiveMode">if set to <c>true</c> [is live mode].</param>
        /// <param name="generator">The generator value.</param>
        void SubmitForm(BasicCameleonFormSubmission submission, bool isLiveMode, string generator);


        /// <summary>
        /// Creates the form.
        /// </summary>
        /// <param name="culture">The culture.</param>
        /// <returns>A Form object.</returns>
        Form CreateForm(Culture culture);


        /// <summary>
        /// Updates the form.
        /// </summary>
        /// <param name="form">The form object.</param>
        void UpdateForm(Form form);


        /// <summary>
        /// Deletes the form.
        /// </summary>
        /// <param name="form">The form object.</param>
        void DeleteForm(Form form);


        /// <summary>
        /// Gets the page.
        /// </summary>
        /// <param name="id">The id of the page.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Page object.</returns>
        Page GetPage(int id, Culture culture);


        /// <summary>
        /// Gets the pages.
        /// </summary>
        /// <param name="formId">The form id.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>A list of pages.</returns>
        IEnumerable<Page> GetPages(int formId, Culture culture);


        /// <summary>
        /// Creates the page.
        /// </summary>
        /// <param name="form">The form object.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Page object.</returns>
        Page CreatePage(Form form, Culture culture);


        /// <summary>
        /// Updates the page.
        /// </summary>
        /// <param name="page">The page object.</param>
        void UpdatePage(Page page);


        /// <summary>
        /// Deletes a page.
        /// </summary>
        /// <param name="page">The page object.</param>
        void DeletePage(Page page);


        /// <summary>
        /// Gets the element.
        /// </summary>
        /// <param name="id">The id of the element.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Element object.</returns>
        Element GetElement(int id, Culture culture);


        /// <summary>
        /// Gets the elements.
        /// </summary>
        /// <param name="formId">The form id.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The List of Elements.</returns>
        IEnumerable<Element> GetElements(int formId, Culture culture);


        /// <summary>
        /// Creates the element.
        /// </summary>
        /// <param name="page">The page object.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Element object.</returns>
        Element CreateElement(Page page, Culture culture);


        /// <summary>
        /// Updates the element.
        /// </summary>
        /// <param name="element">The Element object.</param>
        void UpdateElement(Element element);


        /// <summary>
        /// Deletes the Element.
        /// </summary>
        /// <param name="element">The Element object.</param>
        void DeleteElement(Element element);


        /// <summary>
        /// Gets the choice.
        /// </summary>
        /// <param name="id">The choice id.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Choice object.</returns>
        Choice GetChoice(int id, Culture culture);


        /// <summary>
        /// Gets the choices.
        /// </summary>
        /// <param name="elementId">The element id.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The list of choices.</returns>
        IEnumerable<Choice> GetChoices(int elementId, Culture culture);


        /// <summary>
        /// Creates a choice.
        /// </summary>
        /// <param name="element">The element object.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Choice object.</returns>
        Choice CreateChoice(Element element, Culture culture);


        /// <summary>
        /// Updates the choice.
        /// </summary>
        /// <param name="choice">The choice object.</param>
        void UpdateChoice(Choice choice);


        /// <summary>
        /// Deletes the choice.
        /// </summary>
        /// <param name="choice">The choice.</param>
        void DeleteChoice(Choice choice);


        /// <summary>
        /// Gets the submission.
        /// </summary>
        /// <param name="id">The Submission Id.</param>
        /// <returns>The submission object.</returns>
        Submission GetSubmission(int id);


        /// <summary>
        /// Gets the submissions.
        /// </summary>
        /// <param name="formId">The form id.</param>
        /// <returns>The list of submissions.</returns>
        IEnumerable<Submission> GetSubmissions(int formId);


        /// <summary>
        /// Gets the submissions.
        /// </summary>
        /// <param name="formId">The form id.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="pageUrl">The page URL.</param>
        /// <returns>The list of Submissions.</returns>
        IEnumerable<Submission> GetSubmissions(int formId, Culture culture, DateTime? startDate, DateTime? endDate, string pageUrl);


        /// <summary>
        /// Creates the submission.
        /// </summary>
        /// <param name="formId">The form id.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The Submission object.</returns>
        Submission CreateSubmission(int formId, Culture culture);


        /// <summary>
        /// Updates the submission.
        /// </summary>
        /// <param name="submission">The submission.</param>
        void UpdateSubmission(Submission submission);


        /// <summary>
        /// Gets the submission value.
        /// </summary>
        /// <param name="id">The SubmissionValue id.</param>
        /// <returns>The SubmissionValue object.</returns>
        SubmissionValue GetSubmissionValue(int id);


        /// <summary>
        /// Gets the submission values.
        /// </summary>
        /// <param name="submissionId">The submission id.</param>
        /// <returns>The list of SubmissionValues.</returns>
        IEnumerable<SubmissionValue> GetSubmissionValues(int submissionId);


        /// <summary>
        /// Creates the submission value.
        /// </summary>
        /// <param name="submissionId">The submission id.</param>
        /// <returns>The SubmissionValue object.</returns>
        SubmissionValue CreateSubmissionValue(int submissionId);


        /// <summary>
        /// Updates the submission value.
        /// </summary>
        /// <param name="value">The value.</param>
        void UpdateSubmissionValue(SubmissionValue value);


        /// <summary>
        /// Gets the submission value item.
        /// </summary>
        /// <param name="id">The SubmissionValueItem id.</param>
        /// <returns>The SubmissionValueItem object.</returns>
        SubmissionValueItem GetSubmissionValueItem(int id);

        /// <summary>
        /// Gets the submission value items.
        /// </summary>
        /// <param name="submissionValueId">The submission value id.</param>
        /// <returns>The list of SubmissionValueItems.</returns>
        IEnumerable<SubmissionValueItem> GetSubmissionValueItems(int submissionValueId);

        /// <summary>
        /// Creates the submission value item.
        /// </summary>
        /// <param name="submissionValueId">The submission value id.</param>
        /// <returns>The SubmissionValueItem object.</returns>
        SubmissionValueItem CreateSubmissionValueItem(int submissionValueId);

        /// <summary>
        /// Updates the submission value item.
        /// </summary>
        /// <param name="item">The SubmissionValueItem object.</param>
        void UpdateSubmissionValueItem(SubmissionValueItem item);
    }
}